package com.timeDeal.servlet;





import com.timeDeal.bean.JingbiaoBean;
import com.timeDeal.bean.UserBean;
import com.timeDeal.bean.XuqiufabuBean;
import com.timeDeal.service.JIngbiaoServicce;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


/**
 * Created by Administrator on 2016/7/24.
 */

public class TijiaoJingbiaoServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, IOException {
        System.out.println("22222222222222222222222");
        String jingbiaoyoushi = request.getParameter("jingbiaoyoushi");
        String jingbiaotiaojian = request.getParameter("jingbiaotiaojian");
        String xuqiuid = request.getParameter("xuiquid");
        int  id = ((UserBean)request.getSession().getAttribute("USER")).getYonghuid() ;
        JingbiaoBean jb = new JingbiaoBean() ;
        jb.setJingbiaorenid(id);
        System.out.println(xuqiuid);
        jb.setXuqiufabuid(Integer.valueOf(xuqiuid.trim()));
        jb.setJingbiaoyoushi(jingbiaoyoushi);
        jb.setJingbiaotiaojian(jingbiaotiaojian);
        JIngbiaoServicce js =new  JIngbiaoServicce();
        try {
            boolean result = js.tijiaoJingbiao(jb,"xuqiufabu") ;
            if (result) {
                PrintWriter out = response.getWriter();
                out.print("竞标成功!") ;
                request.getRequestDispatcher("/user/zhujiemiangg.jsp?leixing=xuqiufabu&tiaojiao=redu&currentpage=1").forward(request,response);
            } else {
                PrintWriter out = response.getWriter();
                out.print("<script contentType=“text/html;charset=UTF-8”>alert(\"error!\");</script>") ;
                response.setHeader("refresh","0;url=/TimeDeal/user/login.jsp");
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}